package com.tsingteng.cosfun.ui.focus.adapter;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.tsingteng.cosfun.R;
import com.tsingteng.cosfun.bean.Attentionbean;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class AttentionAdapter extends BaseAdapter {
    Context mContext = null;
    ViewHolder viewHolder = null;
    List<Attentionbean> list = null;
    Resources rs = null;

    public AttentionAdapter(Context mContext, Activity activity, List<Attentionbean> list) {
        this.mContext = mContext;
        this.list = list;
        rs = mContext.getResources();

    }

    @Override
    public int getCount() {
        if (list == null)
            return 20;
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.attention_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.img = convertView.findViewById(R.id.attention_item_img);
            viewHolder.name_tv = convertView.findViewById(R.id.attention_item_name);
            viewHolder.des_tv = convertView.findViewById(R.id.attention_item_des);
            viewHolder.att_tv = convertView.findViewById(R.id.attention_item_attention);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

//        Glide.with(mContext)
//                .load(list.get(position).getPath())
//                .into(viewHolder.img);
        return convertView;
    }

    public class ViewHolder {
        TextView name_tv;
        TextView des_tv;
        TextView att_tv;
        CircleImageView img;
    }
}
